package cc.ttiot.service.dataCollection.serial;

import com.pi4j.io.serial.SerialConfig;
import com.serotonin.modbus4j.exception.ModbusInitException;

import java.io.IOException;

/**
 * @Description: TODO
 * @Author WangSuheng
 * @Date 2021/10/1 14:41
 * @Version 1.0
 */
public interface SerialCollection {


    /**
     * 串口初始化默认配置:
     * "--device (device-path)"                   [DEFAULT: /dev/ttyAMA0]
     * "--baud (baud-rate)"                       [DEFAULT: 9600]
     * "--data-bits (5|6|7|8)"                    [DEFAULT: 8]
     * "--parity (none|odd|even)"                 [DEFAULT: none]
     * "--stop-bits (1|2)"                        [DEFAULT: 1]
     * "--flow-control (none|hardware|software)"  [DEFAULT: none]
     */
    void init() throws ModbusInitException;

    //初始化串口以指定serialConfig配置
    void init(SerialConfig serialConfig) throws ModbusInitException;

    //单次采集数据
    short[] collect();

    //关闭串口
    void close();
}
